#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
struct E
{
	int x1, x2, y1, y2;
	inline E() {}
	inline E(int x1, int x2, int y1, int y2) : x1(x1), x2(x2), y1(y1), y2(y2) {}
	inline E &operator+=(const E &o)
	{ x1 = min(x1, o.x1), x2 = max(x2, o.x2), y1 = min(y1, o.y1), y2 = max(y2, o.y2); return *this; }
}	a[500009]; int nx, ny, n, x, y, id[500009]; ll ans;
namespace DSU
{
	int fa[500009];
	inline void init(int x) { For(i, 1, x) fa[i] = i; }
	inline int fat(int x) { return x == fa[x] ? x : fa[x] = fat(fa[x]); }
	inline bool issame(int x, int y) { return fat(x) == fat(y); }
	inline void union_(int x, int y) { a[x] += a[y], fa[y] = x; }
}
namespace ST
{
	struct node { vector < int > p, q; } t[500009 << 2]; int n, m;
	inline void build(int x) { m = 2 << __lg(n = x); }
	template < class F > inline void wrk(int p, const F &&f)
	{ if ( p >= 1 && p <= n ) for ( p += m ; p ; p >>= 1 ) f(t[p]); }
	template < class F > inline void wrk(int l, int r, const F &&f)
	{
		for ( l += m - 1, r += m + 1 ; l ^ r ^ 1 ; l >>= 1, r >>= 1 )
		{ if ( ~l & 1 ) f(t[l ^ 1]); if ( r & 1 ) f(t[r ^ 1]); }
	}
}
int main()
{
	freopen("grid.in", "r", stdin), freopen("grid.out", "w", stdout);
	cin.tie(nullptr) -> sync_with_stdio(false);
	cin >> nx >> ny >> n, DSU::init(n), ST::build(nx);
	For(i, 1, n) cin >> x >> y, a[i] = E(x, x, y, y);
	iota(id + 1, id + n + 1, 1), sort(id + 1, id + n + 1, [&](int x, int y) { return a[x].y2 < a[y].y2; });
	For(i, 1, n)
	{
		for ( bool flg = true ; flg ; )
		{
			const auto mrg = [&](int o, vector < int > &vec) {
				for ( ; vec.size() ; vec.pop_back() )
					if ( ( x = vec.back() ) == DSU::fat(x) )
						if ( a[x].y2 >= a[id[i]].y1 - o ) DSU::union_(id[i], x), flg = true; else return;
			}; flg = false;
			For(_, 0, 2) ST::wrk(a[id[i]].x1 - _, [&](auto &nd) { mrg(2 - _, nd.q); }),
						 ST::wrk(a[id[i]].x2 + _, [&](auto &nd) { mrg(2 - _, nd.q); });
			ST::wrk(a[id[i]].x1, a[id[i]].x2, [&](auto &nd) { mrg(2, nd.p); });
		}
		ST::wrk(a[id[i]].x1, [&](auto &nd) { nd.p.push_back(id[i]); });
		ST::wrk(a[id[i]].x2, [&](auto &nd) { nd.p.push_back(id[i]); });
		ST::wrk(a[id[i]].x1, a[id[i]].x2, [&](auto &nd) { nd.q.push_back(id[i]); });
	}
	For(i, 1, n) if ( i == DSU::fat(i) ) ans += ( a[i].x2 - a[i].x1 + 1ll ) * ( a[i].y2 - a[i].y1 + 1ll );
	return cout << ans << '\n', 0;
}
